<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <script src="./index.js"></script>

  <script>
    // 深拷贝
    const arr = ['八维', null, /\.(c|sc|le)ss$/, '海湾',
      {
        name: 1,
        age: 13,
        address: {
          b: {
            c: {
              d: 'hello world'
            }
          }
        }
      }
    ]
    console.log('拷贝前的数据: ', arr)

    // const brr = JSON.parse(JSON.stringify(arr))
    // // brr[2] = { address: 'jjj' }
    // // arr[0] = '🇺🇸'
    // console.log(brr, '我是拷贝后的数据')
    // console.log(arr, '我是考前的数据')

    function deepClone(target) {
      let result;
      let types = Object.prototype.toString.call(target);
      switch (types) {
        case "[object Null]":
          result = target;
          break;
        case "[object Object]":
          result = {}
          for (let i in target) {
            result[i] = deepClone(target[i])
          }
          break;
        case "[object Array]":
          result = []
          for (let i in target) {
            result.push(deepClone(target[i]))
          }
          break;
        case "[object RegExp]":
          result = target;
          break;
        default: // 除了以上数据以外的值；
          result = target;
      }
      return result;
    }

    let copyRes = deepClone(arr)
    console.log(copyRes, '拷贝后的数据')



    const repeatArr = ['bawei', 'bawei', 'bawei', 'jjj', 1, 1, 1, 2, 2, 2, 2, 3, 3, 3]
    console.log([...new Set(repeatArr)])

    console.log(Array.from(new Set(repeatArr)))


    function noRepeat(arr) {
      return arr.reduce((param, item) => {
        param.indexOf(item) === -1 && param.push(item)
        return param;
      }, [])
    }
    console.log(noRepeat(repeatArr), '-----reduce')


    // 字符串重复
    const str = '朱贺成;'
    // const str1 = '肖文轩'
    // console.log(str.repeat(5))

    // includes 数组和字符串的方法
    const banzhang = '李祥s1802b-plus'
    const xuewei = '姜雨馨s1802B'

    const res = banzhang.includes('B')
    console.log(res, 'res')



  </script>
</body>

</html>